#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

template<typename T=int>
inline T read() {
    T x;
    cin >> x;
    return x;
}


int main() {

    deque<int> Q;
    stack<int> S;
    int n = read();
    cout << n << endl;
    for (; n--;) {
        S.push(read());
    }
    while (S.size()) {
        int x = S.top();
        S.pop();
        if (Q.size() > 1) {
            int y = Q.back();
            Q.pop_back();
            Q.push_front(y);
        }
        Q.push_front(x);
    }
    while (Q.size()) {
        cout << Q.front() << " ";
        Q.pop_front();
    }
    return 0;
}
